<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    var arr =[11,12,13,14,15,16];
    function myForeach(arry,fn) {
      for (let index = 0; index < arry.length; index++) {
        // item = arry[index];
        fn(index,arry[index])
      }

    }
    myForeach(arr, function (item, index){
      console.log(item)
      console.log(index)
    })













    
    var arr = [0,2,4,6,5,3,1]
    function myFilter (array, fn) {
      var num = 0;
      for (let i = 0; i < array.length; i++) {
        if (fn(array[i])) {
        num += array[i];
      }       
      } 
      return num;     
    }
    var f = myFilter (arr, function (item) {
      return item % 2 === 0
    })
    console.log(f)
  </script>
</body>
</html>
